package com.ljph.ljaker.model.ext;

import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;

import java.util.List;

/**
 * 良晋商品库 商品
 * Created by yuzhou on 16/9/12.
 */
public class ExtGood extends Model<ExtGood> implements IBean {

    public static final String TABLE_NAME = "ecs_pr_goods";
    public static final String PRIMARY_KEY = "goods_id";
    public static final String CACHE_NAME = "extGoodCache";
    public static final ExtGood dao = new ExtGood();

    public List<ExtGood> findByBrandId(Object brandId) {
        return find("select goods_id, goods_name from " + TABLE_NAME + " where brand_id=?", brandId);
    }

    @Override
    public ExtGood findById(Object idValue) {
        return findFirstByCache(CACHE_NAME, idValue, "select goods_id, goods_name from " + TABLE_NAME + " where goods_id = ?", idValue);
    }

    public Integer getId(){
        return getInt("goods_id");
    }

    public String getName(){
        return get("goods_name");
    }
}
